import request from '@/utils/request'

function getJson () {
  return new Promise((resolve, reject) => {
    request
      .get('/api/')
      .then(res => {
        resolve(res)
      })
      .catch(err => {
        console.log(err)
      })
  })
}

function mockuserlogin () {
  return new Promise((resolve, reject) => {
    request
      .post('/user/login')
      .then(res => {
        resolve(res)
      })
      .catch(err => {
        console.log(err)
      })
  })
}

function login (data) {
  return new Promise((resolve, reject) => {
    request
      .post('/api/login.htm', data)
      .then(res => {
        resolve(res)
      })
      .catch(err => {
        console.log(err)
      })
  })
}

function userinfo () {
  return new Promise((resolve, reject) => {
    request
      .get('/api/user.htm')
      .then(res => {
        resolve(res)
      })
      .catch(err => {
        console.log(err)
      })
  })
}

// 员工-烧制汇总
function cookingUserListDetail (data) {
  return request({
    url: 'https://test-api-report.zhihuishitang.net/report/cookingListDetail/cookingUserListDetail',
    method: 'post',
    data: data,
    headers: {
      accessToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJwYXJhbVwiOntcImNvbXBhbnlJZFwiOlwiMTI1XCIsXCJjb21wYW55TWFuYWdlcklkXCI6XCI5MzdcIixcInR5cGVcIjpcIjFcIn0sXCJ0b2tlbk5hbWVcIjpcImNvbXBhbnlNYW5hZ2VyXCJ9IiwiaWF0IjoxNjM0MTE1OTUxLCJleHAiOjE4OTMzMTU5NTF9.a1CHB1NduYhm6cUKT7MPCnPCTDQakNUqcrC8vBUBf6o9VCB5q8uT-d90-SBy3XqDkegerfw3N_i3qSyA_KbOsg'
    }
  })
}
export {
  getJson,
  mockuserlogin,
  login,
  userinfo,
  cookingUserListDetail
}
